<?php

/*
 * Copyright (c) Madbit 2012. All Rights Reserved.
 * Reproduction in whole or in part is prohibited without the
 * written consent of the copyright owner.
 */
if(isset($_POST['dbname']) 
    && isset($_POST['dbhost'])
    && isset($_POST['dbusername'])
    && isset($_POST['dbpassword'])
    && isset($_POST['db_confirmpassword'])) {
    
    $dbname = $_POST['dbname'];
    $dbhost = $_POST['dbhost'];
    $dbusr = $_POST['dbusername'];
    $dbpdw = $_POST['dbpassword'];
    $dbcpwd = $_POST['db_confirmpassword'];
    
    $connection = mysql_connect($dbhost, $dbusr, $dbpdw)
        or die("warn: DB error connection. Check the values. Back");
    
    if($dbpdw != $dbcpwd) {
        die ("warn: The passwords don't correspond. Back");
    }
    
    include '../SQL/sql.php';
    
    // drop database
    $query = sprintf($dropDB,$dbname);
    $result = mysql_query($query);
    
     // create database
    $query = sprintf($createDB,$dbname);
    $result = mysql_query($query);
    
     // create tables
    $result = mysql_query($createTables);
    
     // inizialize tables
    $result = mysql_query($inizializeTables);
    
    
        
}
 else {
    echo "warn: Fill all the fields.";
}


?>
